﻿using System;
using System.ComponentModel;
using System.Linq.Expressions;
using System.Runtime.CompilerServices;

namespace AutomationMLMapper.MVVM_Framework
{
    public abstract class PropertyChangedBase : INotifyPropertyChanged
    {
        public event PropertyChangedEventHandler PropertyChanged;

        /// <summary>
        /// You call this method from a property setter, leaving out the optional parameter.
        /// The compiler will fill out the parameter for you, passing the PropertyName to this method.
        /// </summary>
        /// <param name="propertyName"></param>
        public void NotifyOfPropertyChange([CallerMemberName] string propertyName = "")
        {
            var handler = PropertyChanged;
            if (handler != null)
                handler(this, new PropertyChangedEventArgs(propertyName));
        }        
    }
}